﻿using System.Linq;
using System.Threading;

namespace VideoSeller.Business.Data
{
	public partial class Category
	{
		 public string Title 
		 {
			 get
			 {
				 if (!CategoryLocalizations.Any())
				 {
					 return string.Empty;
				 }

				 var result = CategoryLocalizations.SingleOrDefault(x => x.CultureName == Thread.CurrentThread.CurrentCulture.Name);

				 if (result != null)
				 {
					 return result.Title;
				 }

				 result = CategoryLocalizations.SingleOrDefault(x => x.CultureName == "en-US");

				 if (result != null)
				 {
					 return result.Title;
				 }

				 return CategoryLocalizations.First().Title;
			 }
		 }
	}
}